package com.totoro.domain;

import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * 定义用户类实体
 */
@Entity
@Table(name = "user")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class User extends BaseDomain {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;

	private String username;// 用户名

	private String password;// 密码

	@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
	@JoinColumn(name = "actor_id")
	private Actor actor;// 参与者

	/*
	 * 1.一对多要添加mappedBy映射， 2.FetchType.EAGER：急加载，加载一个实体时，定义急加载的属性会立即从数据库中加载
	 */
	@OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
	private Collection<UserRole> userRole;// 关联的UserRole类

	private Boolean enableToLogin;// 账户过期否

	/**
	 * @generated
	 */
	@Column(name = "picture_id")
	private String picture;// 头像

	private String sigurePicture;// 签名图片

	// 构造空的构造器
	public User() {
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Actor getActor() {
		return actor;
	}

	public void setActor(Actor actor) {
		this.actor = actor;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public Collection<UserRole> getUserRole() {
		return userRole;
	}

	public void setUserRole(Collection<UserRole> userRole) {
		this.userRole = userRole;
	}

	public Boolean getEnableToLogin() {
		return enableToLogin;
	}

	public void setEnableToLogin(Boolean enableToLogin) {
		this.enableToLogin = enableToLogin;
	}

	public String getPicture() {
		return picture;
	}

	public void setPicture(String picture) {
		this.picture = picture;
	}

	public String getSigurePicture() {
		return sigurePicture;
	}

	public void setSigurePicture(String sigurePicture) {
		this.sigurePicture = sigurePicture;
	}

}